package com.tbit.uqbike.object.pojo;

import com.tbit.uqbike.manager.exception.BaseException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author chenmengran
 * @Description: 计费规则
 * @date 2019\12\26 002616:50
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddCountFee {

    private Integer feeId;

    private Integer accountId;

    private String name;
    /**
     * 免费时间
     */
    private Integer freeTime;
    /**
     * 起步时间
     */
    private Integer baseTime;
    /**
     * 起步金额
     */
    private Integer baseTimeFee;
    /**
     * 超时时间
     */
    private Integer overTime;
    /**
     * 超时时间费用
     */
    private Integer overTimeFee;

    /**
     * 起步里程数
     */
    private Integer baseMile;
    /**
     * 起步里程费用
     */
    private Integer baseMileFee;
    /**
     * 超里程数
     */
    private Integer overMile;
    /**
     * 超里程费用
     */
    private Integer overMileFee;

    /**
     * 计时封顶分钟数
     */
    private Integer capTime;
    /**
     * 计时封顶金额
     */
    private Integer capTimeFee;
    /**
     * 里程封顶公里数
     */
    private Integer capMile;
    /**
     * 里程封顶金额
     */
    private Integer capMileFee;

    /**
     * 新用户优惠次数
     */
    private Integer newUserFreeTimes;
    /**
     * 优惠次数时长
     */
    private Integer newUserFreeTime;

    /**
     * 调度费开关
     */
    private Integer dispatchSwitch;
    /**
     * 站外短信开关
     */
    private Integer areaSmsSwitch;
    /**
     * 站外调度费
     */
    private Integer areaMoney;
    /**
     * 站外免费次数
     */
    private Integer areaOutsideFreeTimes;
    /**
     * 超区短信开关
     */
    private Integer parkPointSmsSwitch;
    /**
     * 超区调度费
     */
    private Integer parkPointMoney;

    /**
     * 禁停区调度费开关(0:关闭 1:打开)
     */
    private Integer noParkAreaSwitch;

    /**
     * 禁停区调度费
     */
    private Integer noParkAreaMoney;
    /**
     * 超区免费次数
     */
    private Integer parkPointOutsideFreeTimes;
    /**
     * 首充金额
     */
    private Integer newUserRechcrge;

    /**
     * 借车限制金额
     */
    private Integer rechargeBase;

    private Integer deposit;

    private Date addTime;

    private String userCode;

    private String operaPsw;
    /**
     * 免费骑行时间内是否收取调度费
     */
    private Integer freeTimeDispatch;
    /**
     * 每日前免费骑行次数
     */
    private Integer freeRideTime;
    /**
     * 头盔锁罚款开关（0：关闭，1：开启）
     */
    private int helmetSwitch;
    /**
     * 头盔锁罚款费用
     */
    private int helmetMoney;
    /**
     * 免费骑行满足条件 0:满足全部启用条件 1:满足任一启用条件
     */
    private Integer freeConditionType;
    /**
     * 每次前多少米骑行免费
     */
    private Integer freeDistance;

    public AddCountFee(Integer feeId) {
        this.feeId = feeId;
    }

    public static boolean validate(Integer a, Integer b) {
        //两个都为空
        boolean bothNull = a == null && b == null;
        //两个都等于0
        boolean bothZero = a != null && a == 0 && b != null && b == 0;
        //两个都大于0
        boolean bothMoreThanZero = a != null && a > 0 && b != null && b > 0;
        return bothNull || bothZero || bothMoreThanZero;
    }

    public void checkCapFee() {
        if (!validate(this.capTime, this.capTimeFee)) {
            throw new BaseException("收费封顶[按分钟]-请设置两项都为零或都大于0");
        }
        if (!validate(this.capMile, this.capMileFee)) {
            throw new BaseException("收费封顶[按公里]-请设置两项都为零或都大于0");
        }
    }


}
